{include file="public/header"/}

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">

            <div class="ibox-title">
                <h5>机器人批量导入</h5>
                <div class="ibox-tools">
                </div>
            </div>

            <div class="ibox-content">

            <div class="row search-form">
                <div class="col-sm-13">
                    <form id="search_form" class="form-search form-inline" method="get" action="">


                        <div class="col-sm-3">
 
                             <div class="input-group">
                                <span class="input-group-btn">
                                    <a href="javascript:;" data-toggle="modal" data-target="#myModal" class="btn btn-primary" id="exportBtn"><i class="fa fa-plus"></i> 上传用户文件</a>
                                </span>
                            </div>

   
                        </div>

                    </form>
                </div>
            </div>
                <div class="example-wrap">
                    <div class="example table-responsive">
                        <table class="table table-bordered table-hover">
                            <thead>
                            <tr class="long-tr">
                                <th width="10%">批次号</th>
                                <th width="10%">导入总数</th>
                                 <th width="10%">段位名称</th>
                                <th width="10%">创建人</th>
                                <th width="10%">说明</th>
                                <th width="10%">状态</th>
                                <th width="15%">创建时间</th>
                                <th width="15%">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name="list_data" id="vo"}
                                <tr class="long-td">
                                    <td>{$vo.batch_no}</td>
                                    <td>{$vo.import_total}</td>
                                    <td>{$vo.grad_name}</td>
                                    <td>{$vo.name}</td>
                                    <td>{$vo.remark}</td>
                                    <td>{$status_arr[$vo.status]}</td>
                                    <td>{$vo.create_time|date='Y-m-d H:i:s',###}</td>
                                    <td>
                                        <a href="{:url('import_user',['id'=>$vo.id])}" class="btn btn-primary btn-xs">
                                            <i class="fa"></i>导入用户</a>
                                        <a href="{$vo.url}" target="_blank" class="btn btn-primary btn-xs">
                                            <i class="fa fa-file-excel-o"></i>下载文件</a>
                                    </td>
                                </tr>
                            {/volist}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>


    </div>
        </div>
    </div>
</div>

<div class="modal inmodal" id="myModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated bounceInRight">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">填写信息</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="{:url('save_setting')}" method="post" id="save_form">
                <p class="normal_tips"><b class="fa fa-info-circle"></b> 温馨提示：
                    <br/>
                    1、上传文件必须为xlsx,xls格式;
                </p>

                <div class="form-group">
                    <label>段位名称</label>
                     <select class="form-control" name="gid">
                        {if $lists}
                        {foreach name="lists" item="v"}
                        <option value="{$v.id}" style="margin-left:55px;">{$v.name}</option>
                        {/foreach}
                        {/if}
                     </select>
                </div>
                <div class="form-group">
                    <label>规则类型</label>
                    <select class="form-control" name="rule_type" id="rule_type">
                        <option value="">请选择</option>
                        <option value="1">低</option>
                        <option value="2">中</option>
                        <option value="3">高</option>
                    </select>
                </div>
                <div class="form-group">
                    <label>创建人</label>
                    <input type="text" id="name" name="name" placeholder="请输入创建人" class="form-control">
                </div>
                
                <div class="form-group">
                    <label>说明</label>
                    <textarea id="remark" name="remark" placeholder="请输入说明" class="form-control"></textarea>
                </div>

                <div class="form-item cf toggle-file_id">
                <label class="item-label">上传文件<span class="check-tips"></span></label>
                <div class="controls">
                  <div class="controls upload_file" rel="file_id">
                        <div id="upload_file_file_id" class="uploadify" style="height: 30px; width: 120px;">
                            <div id="upload_file_file_id-button" class="uploadify-button " style="height: 30px; line-height: 30px; width: 120px;"><span class="uploadify-button-text">上传附件</span></div></div>
                                <div id="upload_file_file_id-queue" class="uploadify-queue"></div>
                                <input type="hidden" name="file_id" value="">
                                <div class="upload-img-box">
                                  <div class="upload-pre-file" style="display: none;">
                                    <span class="upload_icon_all"></div>                            
                                  </div>
                            </div>                    
                        </div>
                </div>

                <div class="modal-footer">
                    <input type="hidden" name="url" id="url" value="">
                    <input type="hidden" name="file_name" id="file_name" value="">

                    <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-close"></i> 关闭</button>
                    <button type="submit" id="submit" class="btn btn-primary" target-form="form-horizontal"><i class="fa fa-save"></i> 保存</button>
                </div>

                </form>
            </div>
            
        </div>
    </div>
</div>

{include file="public/footer" /}

<script type="text/javascript">

    $("#save_form").validate({
        rules: {
            name: {
                required: true,
                rangelength: [2,12]
            },
            remark: {
                required: true,
                rangelength: [1,70]
            },
            file_id: {
                required: true
            }
        },
        onclick:false,
        onkeyup: false,
        onfocusout: false,
        messages:{
            name:{
                required: '请输入创建人',
            },
            remark:{
                required: '请输入说明',
            },
            pic:{
                required: '请上传文件',
            }
        },
        success:function(label){
            $('#myModal').modal('hide');
        },
        showErrors:function(errorMap,errorList){
            var msg = "";
            $.each(errorList,function(i,v){
                layer.msg(v.message,{icon:0,time:2000,shade: 0.1});
                return false;
            })
        }
    });
    

    //上传
    initUploadFile(function(data,name){
        // console.log(data)
        var data = $.parseJSON(data);
        $('#url').val(data.path);   
        $('#file_name').val(data.name);    
        
    });

</script>
</body>
</html>